let system = uni.getSystemInfoSync(); // 获取系统信息
/**检查是否打开GPS功能（android）**/
export const checkOpenGPSServiceByAndroid = () => {
        if (system.platform === 'android') { // 判断平台
          
            openGps();
        }
    }
    /**
     * 定位权限及弹出权限弹框 监听用户点击按钮
     * **/
export const openGps = () => {
    plus.android.requestPermissions(
        ['android.permission.ACCESS_FINE_LOCATION'],
        function(resultObj) {
            console.log('resultObj---', resultObj);
            var result = 0;
            for (var i = 0; i < resultObj.granted.length; i++) {
                var grantedPermission = resultObj.granted[i];
                // console.log(6, '已获取的权限：' + grantedPermission);
                result = 1
            }
            for (var i = 0; i < resultObj.deniedPresent.length; i++) {
                var deniedPresentPermission = resultObj.deniedPresent[i];
                // console.log(5, '拒绝本次申请的权限：' + deniedPresentPermission);
      
                result = 0
            }
            for (var i = 0; i < resultObj.deniedAlways.length; i++) {
                var deniedAlwaysPermission = resultObj.deniedAlways[i];
                // console.log(4, '永久拒绝申请的权限：' + deniedAlwaysPermission);
            
                result = -1
            }
            // 若所需权限被拒绝,则打开APP设置界面,可以在APP设置界面打开相应权限
            if (result != 1) {
                //如果用户第一次拒绝后，跳转到**应用**的权限页面
                 var Intent = plus.android.importClass("android.content.Intent");
                 var Settings = plus.android.importClass("android.provider.Settings");
                 var Uri = plus.android.importClass("android.net.Uri");
                 var mainActivity = plus.android.runtimeMainActivity();
                 var intent = new Intent();
                 intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                 var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
                 intent.setData(uri);
                 mainActivity.startActivity(intent);
            }
        },
        function(error) {
            console.log('申请权限错误：' + error.code + " = " + error.message);
            resolve({
                code: error.code,
                message: error.message
            });
        }
    );
}
 